package com.gxa.controller.shezhicontroller;

import com.gxa.common.R;
import com.gxa.pojo.JiLiangDanWei;
import com.gxa.service.shezhiservice.JiLiangDanWei46Service;
import com.gxa.service.shezhiservice.KeHuType46Service;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author x
 */
@RestController
@RequestMapping("/JiLiangDanWei")
@Api(value = "计量单位管理" , tags = "计量单位数据接口API")
@RequiresPermissions("计量单位")
public class JiLiangDanWeiController {

    @Autowired(required = false)
    public R r;
    @Autowired(required = false)
    public JiLiangDanWei46Service jiLiangDanWei46Service;
    @GetMapping("/selectAllJiLiangDanWeiForPage")
    @ApiOperation(value = "计量查询接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })

    public R selectAllJiLiangDanWeiForPage(@RequestParam int page,@RequestParam int size)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        return r;
        return jiLiangDanWei46Service.selectAllJiLiangDanWeiForPage(page , size);
    }

    @PostMapping("/insertJiLiangDanWei")
    @ApiOperation(value = "新增计量接口",notes="提供计量信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R insertJiLiangDanWei(@RequestBody JiLiangDanWei jiLiangDanWei)
    {
//        r.setCode(200);
//        r.setMsg("查询成功！");
//        return r;
        return jiLiangDanWei46Service.insertJiLiangDanWei(jiLiangDanWei);
    }

    @PostMapping("/updateJiLiangDanWeiById")
    @ApiOperation(value = "修改计量信息接口",notes="提供计量信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateJiLiangDanWeiById(@RequestBody JiLiangDanWei jiLiangDanWei)
    {
//        r.setCode(200);
//        r.setMsg("修改成功！");
//        return r;
        return jiLiangDanWei46Service.updateJiLiangDanWeiById(jiLiangDanWei);
    }

    @PostMapping("/deleteJiLiangDanWeiById")
    @ApiOperation(value = "删除计量接口",notes = "提供计量id",httpMethod = "post",response = R.class)
    @ApiImplicitParam(name="id",value = "主键",required = true,dataType = "int")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteJiLiangDanWeiById(@RequestParam int id)
    {
//        r.setCode(200);
//        r.setMsg("删除成功！");
//        return r;
        return jiLiangDanWei46Service.deleteJiLiangDanWeiById(id);
    }




}
